Skip to content

Skill to compare performance of a branch or PR with main - #22725

Merged
rapids-bot[bot] merged 11 commits into
NVIDIA:mainfrom
mhaseeb123:ai-skill/cudf-perf-compare
Jun 26, 2026
Merged

Skill to compare performance of a branch or PR with main#22725
rapids-bot[bot] merged 11 commits into
NVIDIA:mainfrom
mhaseeb123:ai-skill/cudf-perf-compare

Conversation

@mhaseeb123

@mhaseeb123 mhaseeb123 commented May 30, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a new AI-agent skill to automatically compare the performance of branch or a PR against the rapidsai/cudf/main branch and produce a report

Checklist

  • I am familiar with the Contributing Guidelines.
  • N/A: New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@copy-pr-bot

copy-pr-bot Bot commented May 30, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mhaseeb123

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@mhaseeb123 mhaseeb123 added 2 - In Progress Currently a work in progress ai-agents AI agents instructions related issue feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change labels May 30, 2026
@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8177d0f1-e58b-473f-aae2-54da07623214

📥 Commits

Reviewing files that changed from the base of the PR and between 908a991 and 1fd67f6.

📒 Files selected for processing (1)
  • .agents/skills/perf-compare-cudf/SKILL.md
✅ Files skipped from review due to trivial changes (1)
  • .agents/skills/perf-compare-cudf/SKILL.md

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Added a new workflow guide for benchmarking cuDF changes against the main branch.
    • Covers setup and authentication, running NVBench on a single GPU, selecting benchmark axes/cases, and generating timestamped outputs.
    • Includes instructions for comparing results with nvbench_compare.py, interpreting comparison outcomes (including segfault/end-of-suite behavior), and restoring the original workspace state.

Walkthrough

Adds a documented NVBench workflow for comparing a cuDF target branch against main, covering setup, benchmark selection, target and main runs, comparison generation, and cleanup/reporting requirements.

Changes

cuDF perf-compare skill

Layer / File(s) Summary
Skill setup and target preparation
.agents/skills/perf-compare-cudf/SKILL.md
Adds the skill metadata, remote detection, prerequisites, and the prepare/build steps for the target branch.
Benchmark selection and target run
.agents/skills/perf-compare-cudf/SKILL.md
Describes benchmark discovery, axis selection, and NVBench execution on the target branch with per-benchmark JSON and log outputs.
Main run and comparison
.agents/skills/perf-compare-cudf/SKILL.md
Switches to a temporary main branch, reruns the selected benchmarks, and writes the comparison report.
Restore and report
.agents/skills/perf-compare-cudf/SKILL.md
Returns to the starting state, removes temporary branches, and specifies the required final summary and COMPARISON.md contents.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

improvement

Suggested reviewers

  • vyasr
  • mroeschke
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: a skill for comparing a branch or PR's performance against main.
Description check ✅ Passed The description matches the changeset by describing a new AI-agent skill to compare branch or PR performance against cuDF main.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
.agents/skills/perf-compare-cudf/scripts/compare.py (2)

120-122: ⚡ Quick win

Consider adding error handling for malformed CSV files.

If a CSV file is malformed, csv.DictReader may raise exceptions that would crash the script with an unclear error message. Adding a try/except block would improve user experience.

🛡️ Proposed fix to handle CSV errors gracefully
 def read_rows(path: Path) -> list[dict]:
-    with open(path) as f:
-        return list(csv.DictReader(f))
+    try:
+        with open(path) as f:
+            return list(csv.DictReader(f))
+    except (OSError, csv.Error) as e:
+        raise SystemExit(f"Failed to read {path}: {e}")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.agents/skills/perf-compare-cudf/scripts/compare.py around lines 120 - 122,
The read_rows function uses csv.DictReader without handling malformed CSVs; wrap
the file read and csv.DictReader invocation in a try/except inside read_rows to
catch csv.Error (and optionally UnicodeDecodeError/IOError), log or raise a
clearer, contextual error mentioning the path, and return an empty list or
rethrow a custom exception depending on caller expectations; update references
to read_rows to handle the new return/error behavior if needed.

305-328: ⚡ Quick win

Consider validating input directories in argument parsing.

The script doesn't validate that --pr and --main point to existing directories. If they don't exist or are files, the error messages later will be unclear (e.g., "no CSVs found" when the directory doesn't exist).

✅ Proposed fix to validate directories early

Add a custom type for directory validation:

+def existing_dir(path_str: str) -> Path:
+    path = Path(path_str)
+    if not path.is_dir():
+        raise argparse.ArgumentTypeError(f"{path} is not a directory")
+    return path
+
 def parse_args() -> argparse.Namespace:
     parser = argparse.ArgumentParser(
         description=__doc__,
         formatter_class=argparse.RawDescriptionHelpFormatter,
     )
     parser.add_argument(
-        "--pr", required=True, type=Path, help="dir with PR-branch CSVs"
+        "--pr", required=True, type=existing_dir, help="dir with PR-branch CSVs"
     )
     parser.add_argument(
-        "--main", required=True, type=Path, help="dir with main-branch CSVs"
+        "--main", required=True, type=existing_dir, help="dir with main-branch CSVs"
     )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.agents/skills/perf-compare-cudf/scripts/compare.py around lines 305 - 328,
The parse_args function currently accepts --pr and --main as Path but doesn't
validate they exist or are directories; add early validation so users get clear
errors: either implement a custom argparse type/validator (used for the --pr and
--main arguments) that checks path.exists() and path.is_dir() and raises
argparse.ArgumentTypeError on failure, or after parser.parse_args() check
args.pr and args.main and raise argparse.ArgumentTypeError (or call
parser.error) if they are missing or not directories; update parse_args to
reference the new validator so bad inputs fail fast and with a clear message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.agents/skills/perf-compare-cudf/scripts/compare.py:
- Around line 120-122: The read_rows function uses csv.DictReader without
handling malformed CSVs; wrap the file read and csv.DictReader invocation in a
try/except inside read_rows to catch csv.Error (and optionally
UnicodeDecodeError/IOError), log or raise a clearer, contextual error mentioning
the path, and return an empty list or rethrow a custom exception depending on
caller expectations; update references to read_rows to handle the new
return/error behavior if needed.
- Around line 305-328: The parse_args function currently accepts --pr and --main
as Path but doesn't validate they exist or are directories; add early validation
so users get clear errors: either implement a custom argparse type/validator
(used for the --pr and --main arguments) that checks path.exists() and
path.is_dir() and raises argparse.ArgumentTypeError on failure, or after
parser.parse_args() check args.pr and args.main and raise
argparse.ArgumentTypeError (or call parser.error) if they are missing or not
directories; update parse_args to reference the new validator so bad inputs fail
fast and with a clear message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b8b8438e-8438-4aff-83ca-938bc8371fad

📥 Commits

Reviewing files that changed from the base of the PR and between 9ab352b and 05e475a.

📒 Files selected for processing (2)
  • .agents/skills/perf-compare-cudf/SKILL.md
  • .agents/skills/perf-compare-cudf/scripts/compare.py

@mhaseeb123
mhaseeb123 marked this pull request as ready for review June 5, 2026 03:22
@mhaseeb123
mhaseeb123 requested a review from a team as a code owner June 5, 2026 03:22
@mhaseeb123
mhaseeb123 requested a review from jameslamb June 5, 2026 03:22
@mhaseeb123 mhaseeb123 added 3 - Ready for Review Ready for review by team and removed 2 - In Progress Currently a work in progress labels Jun 5, 2026

@jameslamb jameslamb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sticking this in the same directory as other skills seems right, but beyond that I'm not the best person to review this.

One of the other ci-codeowners who's also a cuDF maintainer, like @vyasr or @bdice , would be bette.r

Think you all should also consider updating CODEOWNERS to have cuDF maintainers, not the build team, review changes in .agents/skills by default.

@mhaseeb123

Copy link
Copy Markdown
Contributor Author

@jameslamb makes sense. I think the ci-codeowners was auto assigned to this PR for some reason.

@mhaseeb123
mhaseeb123 requested review from bdice, kjmph and vyasr June 11, 2026 00:57
## Step 0: Devcontainer + build environment

Read and follow `/build-test-cudf` (skill at `.agents/skills/build-test-cudf/SKILL.md`) to:
- Confirm we are in a cudf devcontainer (username `coder`). If not, stop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to make this skill unusable outside of devcontainers? I wonder if we should be at least setting up our skill such that they have good default behaviors in devcontainers but will have some way to reference alternative options when used in other contexts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Told it to ensure either we are in cudf devcontainer or we have CUDA, required packages, and build helpers in place. Exit if neither available. I would not mind exiting if not in cudf devcontainer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that it's going to be clear to the agent what exactly the requirements are with these situations. Also some of the other details (e.g. latest in the build path) are devcontainer-specific. I think we should just make this skill only work in devcontainers for now, and if someone tries to use it outside of a devcontainer we can ask them to help generalize it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just told it to run in devcontainer (like other skills) or stop and ask the user for instructions. Ok for now I think.

Comment thread .agents/skills/perf-compare-cudf/SKILL.md Outdated
Comment thread .agents/skills/perf-compare-cudf/SKILL.md Outdated
Comment thread .agents/skills/perf-compare-cudf/SKILL.md Outdated
Comment thread .agents/skills/perf-compare-cudf/SKILL.md Outdated
Comment thread .agents/skills/perf-compare-cudf/SKILL.md Outdated
Comment thread .agents/skills/perf-compare-cudf/scripts/compare.py Outdated
@mhaseeb123
mhaseeb123 requested a review from vyasr June 25, 2026 00:09
@mhaseeb123
mhaseeb123 removed the request for review from kjmph June 25, 2026 05:01
@mhaseeb123 mhaseeb123 added 4 - Needs Review Waiting for reviewer to review or respond and removed 3 - Ready for Review Ready for review by team labels Jun 26, 2026

@vyasr vyasr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are still some improvements to be made, but overall this looks good now. I'm approving, but please address the suggestions that make sense to you.

Comment on lines +28 to +32
- Before switching branches, stash unrelated user changes and record the stash name. If the target is the current WIP, keep changes applied for the target run, then stash them before switching to main.
- Check out the PR with:
```bash
gh pr checkout <PR_NUMBER> --repo rapidsai/cudf
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably help the agent by more explicitly laying out the branching here. Checking out the PR is only necessary in the PR case, and is mutually exclusive with the "keep changes applied" case, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in
908a991

## 1. Prepare

- Record the starting branch, `git status --short`, and the exact target (current WIP or cudf PR).
- Before switching branches, stash unrelated user changes and record the stash name. If the target is the current WIP, keep changes applied for the target run, then stash them before switching to main.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we tell the skill to always run the target branch case first since if you're benchmarking WIP code then it places the stash/unstash at well-defined points in the workflow? Otherwise depending on the order the agent will have to decide when to stash and unstash, which introduces another point of failure.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 908a991


- Return to the starting branch, pop any stash you created, delete temporary branches, and confirm `git status` matches the starting state.
- Summarize chat with the headline result (regression, improvement, or within noise), relevant metrics, hardware used, branch SHAs, axis coverage, and generated files.
- Use this report shape for `COMPARISON.md`, adapting the metric columns to the benchmark. GPU time is always useful, but other metrics such as output file size, throughput, compression ratio, or memory usage are also of interest when they change significantly in target vs main.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want it to overwrite the benchmarks results from previous runs? It might be helpful to ask it to deterministically produce a name e.g. benchmark_comparisons/"<<PR #>| WIP>_<date>_COMPARISON.json". A subdirectory would keep this more organized too and avoid polluting the repo root.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually is smart enough not to overwrite results but I put specific instructions in 908a991

## Step 0: Devcontainer + build environment

Read and follow `/build-test-cudf` (skill at `.agents/skills/build-test-cudf/SKILL.md`) to:
- Confirm we are in a cudf devcontainer (username `coder`). If not, stop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that it's going to be clear to the agent what exactly the requirements are with these situations. Also some of the other details (e.g. latest in the build path) are devcontainer-specific. I think we should just make this skill only work in devcontainers for now, and if someone tries to use it outside of a devcontainer we can ask them to help generalize it.

Comment thread .agents/skills/perf-compare-cudf/SKILL.md Outdated

@bdice bdice left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine but I want some proof of it working as expected. Do you have PRs where you've tested this skill?

@mhaseeb123

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit c979f58 into NVIDIA:main Jun 26, 2026
136 checks passed
@mhaseeb123
mhaseeb123 deleted the ai-skill/cudf-perf-compare branch June 26, 2026 22:52
copy-pr-bot Bot pushed a commit that referenced this pull request Jun 29, 2026
This PR adds a new AI-agent skill to automatically compare the performance of  branch or a PR against the `rapidsai/cudf/main` branch and produce a report

Authors:
  - Muhammad Haseeb (https://github.com/mhaseeb123)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Bradley Dice (https://github.com/bdice)
  - Yunsong Wang (https://github.com/PointKernel)

URL: #22725
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 - Needs Review Waiting for reviewer to review or respond ai-agents AI agents instructions related issue feature request New feature or request libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants